package online.heycm.codegenerator.common.types;

import java.util.Arrays;
import online.heycm.platform.common.entity.exception.BizException;

/**
 * 支持的数据库类型
 *
 * @author heycm
 * @since 2023/12/17 19:27
 */
public enum DBType {

    MySQL("com.mysql.cj.jdbc.Driver"),

    Oracle("oracle.jdbc.driver.OracleDriver");

    private final String driver;

    DBType(String driver) {
        this.driver = driver;
    }

    public static DBType of(String name) {
        return Arrays.stream(values()).filter(e -> e.name().equalsIgnoreCase(name)).findAny()
                .orElseThrow(() -> new BizException("无效的数据库类型"));
    }

    public String getDriver() {
        return driver;
    }
}
